package com.gnerv.rabbitmq.agent.command;

import com.gnerv.rabbitmq.agent.model.entity.Node;
import com.gnerv.rabbitmq.agent.tools.ExecTools;
import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author Gnerv LiGen
 */
public class VhostCommand extends AbstractRabbitmqctlCommand {

    public VhostCommand(Node node){
        super();
        setNode(node);
    }

    public static VhostCommand build(Node node) {
        return new VhostCommand(node);
    }

    public ExecTools.ExecResult addVhost(String name, String desc) {
        List<String> listVhosts = Lists.newArrayList();
        listVhosts.add("add_vhost");
        listVhosts.add(name);
        listVhosts.add(desc);
        return run(listVhosts);
    }

    public ExecTools.ExecResult clearVhostLimits(String name) {
        List<String> listVhosts = Lists.newArrayList();
        listVhosts.add("clear_vhost_limits");
        listVhosts.add(name);
        return run(listVhosts);
    }

    public ExecTools.ExecResult deleteVhost(String name) {
        List<String> listVhosts = Lists.newArrayList();
        listVhosts.add("delete_vhost");
        listVhosts.add(name);
        return run(listVhosts);
    }

    public ExecTools.ExecResult setVhostLimits(String name, String definition) {
        List<String> listVhosts = Lists.newArrayList();
        listVhosts.add("set_vhost_limits");
        listVhosts.add(name);
        listVhosts.add(definition);
        return run(listVhosts);
    }

    public ExecTools.ExecResult listVhostLimits() {
        List<String> listVhosts = Lists.newArrayList();
        listVhosts.add("list_vhost_limits");
        return run(listVhosts);
    }

    public ExecTools.ExecResult listVhosts() {
        List<String> listVhosts = Lists.newArrayList();
        listVhosts.add("list_vhosts");
        return run(listVhosts);
    }

}
